using SS.core;
using System;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Globalization;
using System.Threading;
using System.Windows.Forms;
namespace SS
{
	public class FrmudtGroupCustomer : Form
	{
		private class Item
		{
			public string Name;
			public int Value;
			public Item(string name, int value)
			{
				this.Name = name;
				this.Value = value;
			}
			public override string ToString()
			{
				return this.Name;
			}
		}
		private IContainer components = null;
		private Label label1;
		private Label label4;
		private TextBox txtGCustomer_ID;
		private TextBox txtGCustomer_Notes;
		private TextBox txtGCustomer_Name;
		private GroupBox groupBox1;
		private Button tSbExit;
		private Button tSBSave;
		private Button tSBAdd;
		private Button btnDel;
		private Label label2;
		private TextBox txtDiscountIn;
		private Label label5;
		private TextBox txtDiscountOut;
		private Label label6;
		private Label label3;
		private DataGridView dgvGCustomer;
		private DataGridViewTextBoxColumn Column1;
		private DataGridViewTextBoxColumn Column2;
		private DataGridViewTextBoxColumn Column3;
		private Label label7;
		private BindingNavigator bindingNavigator1;
		private ToolStripLabel bindingNavigatorCountItem;
		private ToolStripButton bindingNavigatorMoveFirstItem;
		private ToolStripButton bindingNavigatorMovePreviousItem;
		private ToolStripSeparator bindingNavigatorSeparator;
		private ToolStripTextBox bindingNavigatorPositionItem;
		private ToolStripSeparator bindingNavigatorSeparator1;
		private ToolStripButton bindingNavigatorMoveNextItem;
		private ToolStripButton bindingNavigatorMoveLastItem;
		private ToolStripSeparator bindingNavigatorSeparator2;
		public string _GCustomer_ID = "";
		private Func objFunc = new Func();
		public string Type = "";
		public string strConnection = "";
		public bool checkUpt = false;
		protected override void Dispose(bool disposing)
		{
			if (disposing && this.components != null)
			{
				this.components.Dispose();
			}
			base.Dispose(disposing);
		}
		private void InitializeComponent()
		{
			this.components = new Container();
			DataGridViewCellStyle dataGridViewCellStyle = new DataGridViewCellStyle();
			ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof(FrmudtGroupCustomer));
			this.label1 = new Label();
			this.label4 = new Label();
			this.txtGCustomer_ID = new TextBox();
			this.txtGCustomer_Notes = new TextBox();
			this.txtGCustomer_Name = new TextBox();
			this.groupBox1 = new GroupBox();
			this.label3 = new Label();
			this.txtDiscountOut = new TextBox();
			this.label6 = new Label();
			this.txtDiscountIn = new TextBox();
			this.label5 = new Label();
			this.label2 = new Label();
			this.tSbExit = new Button();
			this.tSBSave = new Button();
			this.tSBAdd = new Button();
			this.btnDel = new Button();
			this.dgvGCustomer = new DataGridView();
			this.Column1 = new DataGridViewTextBoxColumn();
			this.Column2 = new DataGridViewTextBoxColumn();
			this.Column3 = new DataGridViewTextBoxColumn();
			this.label7 = new Label();
			this.bindingNavigator1 = new BindingNavigator(this.components);
			this.bindingNavigatorCountItem = new ToolStripLabel();
			this.bindingNavigatorMoveFirstItem = new ToolStripButton();
			this.bindingNavigatorMovePreviousItem = new ToolStripButton();
			this.bindingNavigatorSeparator = new ToolStripSeparator();
			this.bindingNavigatorPositionItem = new ToolStripTextBox();
			this.bindingNavigatorSeparator1 = new ToolStripSeparator();
			this.bindingNavigatorMoveNextItem = new ToolStripButton();
			this.bindingNavigatorMoveLastItem = new ToolStripButton();
			this.bindingNavigatorSeparator2 = new ToolStripSeparator();
			this.groupBox1.SuspendLayout();
			((ISupportInitialize)this.dgvGCustomer).BeginInit();
			((ISupportInitialize)this.bindingNavigator1).BeginInit();
			this.bindingNavigator1.SuspendLayout();
			base.SuspendLayout();
			this.label1.BackColor = Color.FromArgb(255, 255, 192);
			this.label1.BorderStyle = BorderStyle.Fixed3D;
			this.label1.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 163);
			this.label1.Location = new Point(7, 17);
			this.label1.Name = "label1";
			this.label1.Size = new Size(110, 22);
			this.label1.TabIndex = 0;
			this.label1.Text = "Mã nhóm :";
			this.label1.TextAlign = ContentAlignment.MiddleRight;
			this.label4.BackColor = Color.FromArgb(255, 255, 192);
			this.label4.BorderStyle = BorderStyle.Fixed3D;
			this.label4.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 163);
			this.label4.Location = new Point(7, 73);
			this.label4.Name = "label4";
			this.label4.Size = new Size(110, 22);
			this.label4.TabIndex = 3;
			this.label4.Text = "Ghi chú :";
			this.label4.TextAlign = ContentAlignment.MiddleRight;
			this.txtGCustomer_ID.CharacterCasing = CharacterCasing.Upper;
			this.txtGCustomer_ID.Font = new Font("Arial", 9.75f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.txtGCustomer_ID.Location = new Point(120, 18);
			this.txtGCustomer_ID.Name = "txtGCustomer_ID";
			this.txtGCustomer_ID.Size = new Size(67, 22);
			this.txtGCustomer_ID.TabIndex = 1;
			this.txtGCustomer_ID.Leave += new EventHandler(this.txtGCustomer_ID_Leave);
			this.txtGCustomer_ID.KeyPress += new KeyPressEventHandler(this.txtGCustomer_ID_KeyPress);
			this.txtGCustomer_ID.Enter += new EventHandler(this.txtGCustomer_ID_Enter);
			this.txtGCustomer_Notes.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
			this.txtGCustomer_Notes.Font = new Font("Arial", 9.75f);
			this.txtGCustomer_Notes.Location = new Point(120, 74);
			this.txtGCustomer_Notes.Name = "txtGCustomer_Notes";
			this.txtGCustomer_Notes.Size = new Size(756, 22);
			this.txtGCustomer_Notes.TabIndex = 4;
			this.txtGCustomer_Notes.Leave += new EventHandler(this.txtGCustomer_Notes_Leave);
			this.txtGCustomer_Notes.Enter += new EventHandler(this.txtGCustomer_Notes_Enter);
			this.txtGCustomer_Name.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
			this.txtGCustomer_Name.Font = new Font("Arial", 9.75f);
			this.txtGCustomer_Name.Location = new Point(251, 17);
			this.txtGCustomer_Name.Name = "txtGCustomer_Name";
			this.txtGCustomer_Name.Size = new Size(625, 22);
			this.txtGCustomer_Name.TabIndex = 2;
			this.txtGCustomer_Name.Leave += new EventHandler(this.txtGCustomer_Name_Leave);
			this.txtGCustomer_Name.KeyPress += new KeyPressEventHandler(this.txtGCustomer_Name_KeyPress);
			this.txtGCustomer_Name.Enter += new EventHandler(this.txtGCustomer_Name_Enter);
			this.groupBox1.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right);
			this.groupBox1.BackColor = Color.Transparent;
			this.groupBox1.Controls.Add(this.label3);
			this.groupBox1.Controls.Add(this.txtDiscountOut);
			this.groupBox1.Controls.Add(this.label6);
			this.groupBox1.Controls.Add(this.txtDiscountIn);
			this.groupBox1.Controls.Add(this.label5);
			this.groupBox1.Controls.Add(this.label2);
			this.groupBox1.Controls.Add(this.txtGCustomer_Name);
			this.groupBox1.Controls.Add(this.txtGCustomer_Notes);
			this.groupBox1.Controls.Add(this.txtGCustomer_ID);
			this.groupBox1.Controls.Add(this.label4);
			this.groupBox1.Controls.Add(this.label1);
			this.groupBox1.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.groupBox1.Location = new Point(7, 453);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new Size(886, 106);
			this.groupBox1.TabIndex = 10;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "Thông tin";
			this.label3.AutoSize = true;
			this.label3.Font = new Font("Tahoma", 9f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.label3.Location = new Point(324, 49);
			this.label3.Name = "label3";
			this.label3.Size = new Size(152, 14);
			this.label3.TabIndex = 11;
			this.label3.Text = "[ Chiết xuất tính theo % ]";
			this.txtDiscountOut.CharacterCasing = CharacterCasing.Upper;
			this.txtDiscountOut.Font = new Font("Arial", 9.75f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.txtDiscountOut.Location = new Point(251, 45);
			this.txtDiscountOut.Name = "txtDiscountOut";
			this.txtDiscountOut.Size = new Size(67, 22);
			this.txtDiscountOut.TabIndex = 10;
			this.txtDiscountOut.TextAlign = HorizontalAlignment.Right;
			this.label6.BackColor = Color.FromArgb(255, 255, 192);
			this.label6.BorderStyle = BorderStyle.Fixed3D;
			this.label6.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 163);
			this.label6.Location = new Point(191, 45);
			this.label6.Name = "label6";
			this.label6.Size = new Size(57, 22);
			this.label6.TabIndex = 9;
			this.label6.Text = "Xuất :";
			this.label6.TextAlign = ContentAlignment.MiddleRight;
			this.txtDiscountIn.CharacterCasing = CharacterCasing.Upper;
			this.txtDiscountIn.Font = new Font("Arial", 9.75f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.txtDiscountIn.Location = new Point(120, 46);
			this.txtDiscountIn.Name = "txtDiscountIn";
			this.txtDiscountIn.Size = new Size(67, 22);
			this.txtDiscountIn.TabIndex = 8;
			this.txtDiscountIn.TextAlign = HorizontalAlignment.Right;
			this.label5.BackColor = Color.FromArgb(255, 255, 192);
			this.label5.BorderStyle = BorderStyle.Fixed3D;
			this.label5.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 163);
			this.label5.Location = new Point(7, 45);
			this.label5.Name = "label5";
			this.label5.Size = new Size(110, 22);
			this.label5.TabIndex = 7;
			this.label5.Text = "Chiết khấu nhập :";
			this.label5.TextAlign = ContentAlignment.MiddleRight;
			this.label2.BackColor = Color.FromArgb(255, 255, 192);
			this.label2.BorderStyle = BorderStyle.Fixed3D;
			this.label2.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 163);
			this.label2.Location = new Point(191, 18);
			this.label2.Name = "label2";
			this.label2.Size = new Size(57, 22);
			this.label2.TabIndex = 6;
			this.label2.Text = "Tên gọi :";
			this.label2.TextAlign = ContentAlignment.MiddleRight;
			this.tSbExit.Anchor = (AnchorStyles.Bottom | AnchorStyles.Right);
			this.tSbExit.BackColor = SystemColors.ControlLight;
			this.tSbExit.Cursor = Cursors.Hand;
			this.tSbExit.FlatAppearance.BorderColor = Color.Gray;
			this.tSbExit.FlatStyle = FlatStyle.System;
			this.tSbExit.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.tSbExit.ImageAlign = ContentAlignment.MiddleLeft;
//			this.tSbExit.ImeMode = ImeMode.NoControl;
			this.tSbExit.Location = new Point(807, 565);
			this.tSbExit.Name = "tSbExit";
			this.tSbExit.Size = new Size(86, 28);
			this.tSbExit.TabIndex = 18;
			this.tSbExit.Text = "Thoát  [ ESC ]";
			this.tSbExit.UseVisualStyleBackColor = false;
			this.tSbExit.Click += new EventHandler(this.tSBClose_Click);
			this.tSBSave.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.tSBSave.BackColor = SystemColors.ControlLight;
			this.tSBSave.Cursor = Cursors.Hand;
			this.tSBSave.FlatAppearance.BorderColor = Color.Gray;
			this.tSBSave.FlatStyle = FlatStyle.System;
			this.tSBSave.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.tSBSave.ImageAlign = ContentAlignment.MiddleLeft;
//			this.tSBSave.ImeMode = ImeMode.NoControl;
			this.tSBSave.Location = new Point(109, 565);
			this.tSBSave.Name = "tSBSave";
			this.tSBSave.Size = new Size(96, 28);
			this.tSBSave.TabIndex = 17;
			this.tSBSave.Text = "Ghi nhận  [ F6 ]";
			this.tSBSave.UseVisualStyleBackColor = false;
			this.tSBSave.Click += new EventHandler(this.tSBSave_Click);
			this.tSBAdd.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.tSBAdd.BackColor = SystemColors.ControlLight;
			this.tSBAdd.Cursor = Cursors.Hand;
			this.tSBAdd.FlatAppearance.BorderColor = Color.Gray;
			this.tSBAdd.FlatStyle = FlatStyle.System;
			this.tSBAdd.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.tSBAdd.ImageAlign = ContentAlignment.MiddleLeft;
			//this.tSBAdd.ImeMode = ImeMode.NoControl;
			this.tSBAdd.Location = new Point(7, 565);
			this.tSBAdd.Name = "tSBAdd";
			this.tSBAdd.Size = new Size(100, 28);
			this.tSBAdd.TabIndex = 16;
			this.tSBAdd.Text = "Thêm mới  [ F4 ]";
			this.tSBAdd.UseVisualStyleBackColor = false;
			this.tSBAdd.Click += new EventHandler(this.tSBAdd_Click);
			this.btnDel.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.btnDel.BackColor = SystemColors.ControlLight;
			this.btnDel.Cursor = Cursors.Hand;
			this.btnDel.FlatAppearance.BorderColor = Color.Gray;
			this.btnDel.FlatStyle = FlatStyle.System;
			this.btnDel.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnDel.ImageAlign = ContentAlignment.MiddleLeft;
			this.btnDel.Location = new Point(207, 565);
			this.btnDel.Name = "btnDel";
			this.btnDel.Size = new Size(104, 28);
			this.btnDel.TabIndex = 47;
			this.btnDel.Text = "Xoá nhóm  [ F8 ]";
			this.btnDel.UseVisualStyleBackColor = false;
			this.btnDel.Click += new EventHandler(this.btnDel_Click);
			this.dgvGCustomer.AllowUserToAddRows = false;
			this.dgvGCustomer.AllowUserToDeleteRows = false;
			this.dgvGCustomer.AllowUserToResizeColumns = false;
			this.dgvGCustomer.AllowUserToResizeRows = false;
			dataGridViewCellStyle.BackColor = Color.FromArgb(192, 255, 255);
			dataGridViewCellStyle.Font = new Font("Arial", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.dgvGCustomer.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle;
			this.dgvGCustomer.Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right);
			this.dgvGCustomer.BackgroundColor = Color.White;
			this.dgvGCustomer.BorderStyle = BorderStyle.Fixed3D;
			this.dgvGCustomer.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
			this.dgvGCustomer.Columns.AddRange(new DataGridViewColumn[]
			{
				this.Column1,
				this.Column2,
				this.Column3
			});
			this.dgvGCustomer.EnableHeadersVisualStyles = false;
			this.dgvGCustomer.Location = new Point(7, 39);
			this.dgvGCustomer.Name = "dgvGCustomer";
			this.dgvGCustomer.ReadOnly = true;
			this.dgvGCustomer.RowHeadersVisible = false;
			this.dgvGCustomer.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.DisableResizing;
			this.dgvGCustomer.RowTemplate.DefaultCellStyle.BackColor = Color.White;
			this.dgvGCustomer.RowTemplate.DefaultCellStyle.Font = new Font("Arial", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.dgvGCustomer.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
			this.dgvGCustomer.Size = new Size(886, 384);
			this.dgvGCustomer.TabIndex = 48;
			this.dgvGCustomer.CellEnter += new DataGridViewCellEventHandler(this.dgvGCustomer_CellEnter);
			this.Column1.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.Column1.DataPropertyName = "GCustomer_ID";
			this.Column1.HeaderText = "Số hiệu";
			this.Column1.MinimumWidth = 120;
			this.Column1.Name = "Column1";
			this.Column1.ReadOnly = true;
			this.Column1.Width = 120;
			this.Column2.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.Column2.DataPropertyName = "GCustomer_Name";
			this.Column2.HeaderText = "Tên nhóm";
			this.Column2.MinimumWidth = 250;
			this.Column2.Name = "Column2";
			this.Column2.ReadOnly = true;
			this.Column2.Width = 250;
			this.Column3.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
			this.Column3.DataPropertyName = "GCustomer_Notes";
			this.Column3.HeaderText = "Diễn giải";
			this.Column3.Name = "Column3";
			this.Column3.ReadOnly = true;
			this.label7.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
			this.label7.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 0);
			this.label7.Location = new Point(7, 12);
			this.label7.Name = "label7";
			this.label7.Size = new Size(886, 24);
			this.label7.TabIndex = 49;
			this.label7.Text = "DANH MỤC NHÓM KHÁCH HÀNG";
			this.label7.TextAlign = ContentAlignment.MiddleCenter;
			this.bindingNavigator1.AddNewItem = null;
			this.bindingNavigator1.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right);
			this.bindingNavigator1.AutoSize = false;
			this.bindingNavigator1.BackColor = SystemColors.ButtonFace;
			this.bindingNavigator1.CountItem = this.bindingNavigatorCountItem;
			this.bindingNavigator1.CountItemFormat = "/ {0}";
			this.bindingNavigator1.DeleteItem = null;
			this.bindingNavigator1.Dock = DockStyle.None;
			this.bindingNavigator1.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 163);
			this.bindingNavigator1.GripStyle = ToolStripGripStyle.Hidden;
			this.bindingNavigator1.Items.AddRange(new ToolStripItem[]
			{
				this.bindingNavigatorMoveFirstItem,
				this.bindingNavigatorMovePreviousItem,
				this.bindingNavigatorSeparator,
				this.bindingNavigatorPositionItem,
				this.bindingNavigatorCountItem,
				this.bindingNavigatorSeparator1,
				this.bindingNavigatorMoveNextItem,
				this.bindingNavigatorMoveLastItem,
				this.bindingNavigatorSeparator2
			});
			this.bindingNavigator1.Location = new Point(7, 426);
			this.bindingNavigator1.MoveFirstItem = this.bindingNavigatorMoveFirstItem;
			this.bindingNavigator1.MoveLastItem = this.bindingNavigatorMoveLastItem;
			this.bindingNavigator1.MoveNextItem = this.bindingNavigatorMoveNextItem;
			this.bindingNavigator1.MovePreviousItem = this.bindingNavigatorMovePreviousItem;
			this.bindingNavigator1.Name = "bindingNavigator1";
			this.bindingNavigator1.PositionItem = this.bindingNavigatorPositionItem;
			this.bindingNavigator1.RenderMode = ToolStripRenderMode.Professional;
			this.bindingNavigator1.Size = new Size(886, 25);
			this.bindingNavigator1.TabIndex = 142;
			this.bindingNavigator1.Text = "bindingNavigator1";
			this.bindingNavigatorCountItem.Name = "bindingNavigatorCountItem";
			this.bindingNavigatorCountItem.Size = new Size(28, 22);
			this.bindingNavigatorCountItem.Text = "/ {0}";
			this.bindingNavigatorCountItem.ToolTipText = "Total number of items";
			this.bindingNavigatorMoveFirstItem.DisplayStyle = ToolStripItemDisplayStyle.Image;
			//this.bindingNavigatorMoveFirstItem.Image = (Image)componentResourceManager.GetObject("bindingNavigatorMoveFirstItem.Image");
			this.bindingNavigatorMoveFirstItem.Name = "bindingNavigatorMoveFirstItem";
			this.bindingNavigatorMoveFirstItem.RightToLeftAutoMirrorImage = true;
			this.bindingNavigatorMoveFirstItem.Size = new Size(23, 22);
			this.bindingNavigatorMoveFirstItem.Text = "Move first";
			this.bindingNavigatorMovePreviousItem.DisplayStyle = ToolStripItemDisplayStyle.Image;
			//this.bindingNavigatorMovePreviousItem.Image = (Image)componentResourceManager.GetObject("bindingNavigatorMovePreviousItem.Image");
			this.bindingNavigatorMovePreviousItem.Name = "bindingNavigatorMovePreviousItem";
			this.bindingNavigatorMovePreviousItem.RightToLeftAutoMirrorImage = true;
			this.bindingNavigatorMovePreviousItem.Size = new Size(23, 22);
			this.bindingNavigatorMovePreviousItem.Text = "Move previous";
			this.bindingNavigatorSeparator.Name = "bindingNavigatorSeparator";
			this.bindingNavigatorSeparator.Size = new Size(6, 25);
			this.bindingNavigatorPositionItem.AccessibleName = "Position";
			this.bindingNavigatorPositionItem.AutoSize = false;
			this.bindingNavigatorPositionItem.BackColor = SystemColors.ButtonFace;
			this.bindingNavigatorPositionItem.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 163);
			this.bindingNavigatorPositionItem.Name = "bindingNavigatorPositionItem";
			this.bindingNavigatorPositionItem.Size = new Size(50, 21);
			this.bindingNavigatorPositionItem.Text = "0";
			this.bindingNavigatorPositionItem.TextBoxTextAlign = HorizontalAlignment.Center;
			this.bindingNavigatorPositionItem.ToolTipText = "Current position";
			this.bindingNavigatorSeparator1.Name = "bindingNavigatorSeparator1";
			this.bindingNavigatorSeparator1.Size = new Size(6, 25);
			this.bindingNavigatorMoveNextItem.DisplayStyle = ToolStripItemDisplayStyle.Image;
			//this.bindingNavigatorMoveNextItem.Image = (Image)componentResourceManager.GetObject("bindingNavigatorMoveNextItem.Image");
			this.bindingNavigatorMoveNextItem.Name = "bindingNavigatorMoveNextItem";
			this.bindingNavigatorMoveNextItem.RightToLeftAutoMirrorImage = true;
			this.bindingNavigatorMoveNextItem.Size = new Size(23, 22);
			this.bindingNavigatorMoveNextItem.Text = "Move next";
			this.bindingNavigatorMoveLastItem.DisplayStyle = ToolStripItemDisplayStyle.Image;
			//this.bindingNavigatorMoveLastItem.Image = (Image)componentResourceManager.GetObject("bindingNavigatorMoveLastItem.Image");
			this.bindingNavigatorMoveLastItem.Name = "bindingNavigatorMoveLastItem";
			this.bindingNavigatorMoveLastItem.RightToLeftAutoMirrorImage = true;
			this.bindingNavigatorMoveLastItem.Size = new Size(23, 22);
			this.bindingNavigatorMoveLastItem.Text = "Move last";
			this.bindingNavigatorSeparator2.Name = "bindingNavigatorSeparator2";
			this.bindingNavigatorSeparator2.Size = new Size(6, 25);
			base.AutoScaleDimensions = new SizeF(7f, 15f);
			//base.AutoScaleMode = AutoScaleMode.Font;
			this.BackgroundImageLayout = ImageLayout.Stretch;
			base.ClientSize = new Size(900, 600);
			base.Controls.Add(this.bindingNavigator1);
			base.Controls.Add(this.label7);
			base.Controls.Add(this.dgvGCustomer);
			base.Controls.Add(this.btnDel);
			base.Controls.Add(this.tSbExit);
			base.Controls.Add(this.tSBSave);
			base.Controls.Add(this.tSBAdd);
			base.Controls.Add(this.groupBox1);
			this.Cursor = Cursors.Hand;
			this.DoubleBuffered = true;
			this.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 0);
			//base.Icon = (System.Drawing.Icon)componentResourceManager.GetObject("$this.Icon");
			//base.Icon = (Icon)componentResourceManager.GetObject("$this.Icon");
			base.KeyPreview = true;
			base.MaximizeBox = false;
			base.MinimizeBox = false;
			base.Name = "FrmudtGroupCustomer";
			base.ShowInTaskbar = false;
			base.StartPosition = FormStartPosition.CenterScreen;
			this.Text = "Nhóm khách hàng, nhà cung cấp";
			base.Load += new EventHandler(this.frmudtGroupCustomer_Load);
			base.KeyDown += new KeyEventHandler(this.FrmudtGroupCustomer_KeyDown);
			this.groupBox1.ResumeLayout(false);
			this.groupBox1.PerformLayout();
			((ISupportInitialize)this.dgvGCustomer).EndInit();
			((ISupportInitialize)this.bindingNavigator1).EndInit();
			this.bindingNavigator1.ResumeLayout(false);
			this.bindingNavigator1.PerformLayout();
			base.ResumeLayout(false);
		}
		public FrmudtGroupCustomer()
		{
			this.InitializeComponent();
		}
		private void LoadData(string _GCustomer_ID)
		{
			SqlConnection sqlConnection = new SqlConnection(Program.strConnectionString);
			SqlCommand sqlCommand = new SqlCommand();
			sqlCommand.Connection = sqlConnection;
			sqlCommand.CommandText = "SELECT * FROM TabGroupCustomer WHERE GCustomer_ID = '" + _GCustomer_ID + "'";
			sqlConnection.Open();
			SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
			if (sqlDataReader.HasRows)
			{
				while (sqlDataReader.Read())
				{
					this.txtGCustomer_ID.Text = sqlDataReader["GCustomer_ID"].ToString();
					this.txtGCustomer_Name.Text = sqlDataReader["GCustomer_Name"].ToString();
					this.txtGCustomer_Notes.Text = sqlDataReader["GCustomer_Notes"].ToString();
					this.txtDiscountIn.Text = sqlDataReader["DiscountIn"].ToString();
					this.txtDiscountOut.Text = sqlDataReader["DiscountOut"].ToString();
				}
			}
			sqlConnection.Close();
			sqlConnection.Dispose();
		}
		private void frmudtGroupCustomer_Load(object sender, EventArgs e)
		{
			Program.strConnectionString = this.objFunc.strConnectionString;
			Thread.CurrentThread.CurrentCulture = new CultureInfo("en-us");
			groupCustomers groupCustomers = new groupCustomers();
			groupCustomers.loadToDataGridView(this.dgvGCustomer, this.bindingNavigator1);
			if (this._GCustomer_ID != "")
			{
				this.LoadData(this._GCustomer_ID.ToString());
				this.txtGCustomer_ID.Enabled = false;
			}
		}
		private void tSBAdd_Click(object sender, EventArgs e)
		{
			this.txtGCustomer_ID.Text = "";
			this.txtGCustomer_Name.Text = "";
			this.txtGCustomer_Notes.Text = "";
			this._GCustomer_ID = "";
			this.txtDiscountIn.Text = "0";
			this.txtDiscountOut.Text = "0";
			this.txtGCustomer_ID.Enabled = true;
			this.txtGCustomer_ID.Focus();
		}
		private void OnUpdate(int _act)
		{
			SqlConnection sqlConnection = new SqlConnection(Program.strConnectionString);
			SqlCommand sqlCommand = new SqlCommand("ActionOnTabGroupCustomer", sqlConnection);
			sqlCommand.CommandType = CommandType.StoredProcedure;
			sqlCommand.Parameters.Add("@GCustomer_ID", SqlDbType.NVarChar, 50);
			sqlCommand.Parameters.Add("@GCustomer_Name", SqlDbType.NVarChar, 200);
			sqlCommand.Parameters.Add("@GCustomer_Notes", SqlDbType.NVarChar, 200);
			sqlCommand.Parameters.Add("@DiscountIn", SqlDbType.Float);
			sqlCommand.Parameters.Add("@DiscountOut", SqlDbType.Float);
			sqlCommand.Parameters.Add("@Act", SqlDbType.SmallInt);
			sqlCommand.Parameters["@GCustomer_ID"].Value = this.txtGCustomer_ID.Text.Trim().ToUpper();
			sqlCommand.Parameters["@GCustomer_Name"].Value = this.txtGCustomer_Name.Text;
			sqlCommand.Parameters["@GCustomer_Notes"].Value = this.txtGCustomer_Notes.Text;
			try
			{
				sqlCommand.Parameters["@DiscountIn"].Value = float.Parse(this.txtDiscountIn.Text);
			}
			catch
			{
				sqlCommand.Parameters["@DiscountIn"].Value = 0;
			}
			try
			{
				sqlCommand.Parameters["@DiscountOut"].Value = float.Parse(this.txtDiscountOut.Text);
			}
			catch
			{
				sqlCommand.Parameters["@DiscountOut"].Value = 0;
			}
			sqlCommand.Parameters["@Act"].Value = _act;
			sqlConnection.Open();
			sqlCommand.ExecuteNonQuery();
			this._GCustomer_ID = this.txtGCustomer_ID.Text;
			sqlConnection.Close();
			sqlConnection.Dispose();
			this.checkUpt = true;
		}
		private bool CheckValue(string _GID)
		{
			SqlConnection sqlConnection = new SqlConnection(Program.strConnectionString);
			SqlCommand sqlCommand = new SqlCommand("SELECT * FROM TabGroupCustomer WHERE GCustomer_ID = @GCustomer_ID", sqlConnection);
			sqlCommand.Parameters.Add("@GCustomer_ID", SqlDbType.NVarChar, 50);
			sqlCommand.Parameters["@GCustomer_ID"].Value = _GID;
			sqlConnection.Open();
			SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
			bool result = sqlDataReader.HasRows;
			sqlConnection.Close();
			sqlConnection.Dispose();
			return result;
		}
		private void tSBSave_Click(object sender, EventArgs e)
		{
			if ((this.txtGCustomer_ID.Text != string.Empty && this.txtGCustomer_Name.Text != string.Empty) || this.txtDiscountIn.Text == string.Empty || this.txtDiscountOut.Text == string.Empty)
			{
				if (this._GCustomer_ID != string.Empty)
				{
					this.OnUpdate(1);
				}
				else
				{
					if (this.CheckValue(this.txtGCustomer_ID.Text.Trim().ToUpper()))
					{
						MessageBox.Show("Mã nhóm  " + this.txtGCustomer_ID.Text.Trim().ToUpper() + " đã tồn tại trong hệ thống!", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
						return;
					}
					this.OnUpdate(0);
				}
				groupCustomers groupCustomers = new groupCustomers();
				groupCustomers.loadToDataGridView(this.dgvGCustomer, this.bindingNavigator1);
			}
			else
			{
				MessageBox.Show("Xin vui lòng điền đầy đủ thông tin cần thiết!", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
			}
		}
		private void tSBClose_Click(object sender, EventArgs e)
		{
			base.Close();
		}
		public void DeleteGCustomer(string _GCID)
		{
			SqlConnection sqlConnection = new SqlConnection(Program.strConnectionString);
			SqlCommand sqlCommand = new SqlCommand("DELETE FROM TabGroupCustomer WHERE  [GCustomer_ID] = @GCustomer_ID", sqlConnection);
			sqlCommand.Parameters.Add("@GCustomer_ID", SqlDbType.NVarChar, 50);
			sqlCommand.Parameters["@GCustomer_ID"].Value = _GCID;
			sqlConnection.Open();
			sqlCommand.ExecuteNonQuery();
			sqlConnection.Close();
			sqlConnection.Dispose();
		}
		private void txtGCustomer_ID_KeyPress(object sender, KeyPressEventArgs e)
		{
			if (e.KeyChar == '\r')
			{
				this.txtGCustomer_Name.Focus();
			}
		}
		private void txtGCustomer_Name_KeyPress(object sender, KeyPressEventArgs e)
		{
			if (e.KeyChar == '\r')
			{
				this.txtDiscountIn.Focus();
			}
		}
		private void cbbGCustomer_Type_KeyPress(object sender, KeyPressEventArgs e)
		{
			if (e.KeyChar == '\r')
			{
				this.txtGCustomer_Notes.Focus();
			}
		}
		private void txtGCustomer_ID_Leave(object sender, EventArgs e)
		{
			this.txtGCustomer_ID.BackColor = Color.White;
		}
		private void txtGCustomer_Name_Leave(object sender, EventArgs e)
		{
			this.txtGCustomer_Name.BackColor = Color.White;
		}
		private void txtGCustomer_Notes_Leave(object sender, EventArgs e)
		{
			this.txtGCustomer_Notes.BackColor = Color.White;
		}
		private void txtGCustomer_ID_Enter(object sender, EventArgs e)
		{
			this.txtGCustomer_ID.BackColor = Color.Aqua;
		}
		private void txtGCustomer_Name_Enter(object sender, EventArgs e)
		{
			this.txtGCustomer_Name.BackColor = Color.Aqua;
		}
		private void txtGCustomer_Notes_Enter(object sender, EventArgs e)
		{
			this.txtGCustomer_Notes.BackColor = Color.Aqua;
		}
		private void btnDel_Click(object sender, EventArgs e)
		{
			try
			{
				if (MessageBox.Show("Có phải bạn muốn xoá mục được chọn không?\r\n\r\nBấm YES nếu đồng ý xoá, Bấm NO để bỏ qua!", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
				{
					groupCustomers groupCustomers = new groupCustomers();
					if (this.CheckGroupHavePartner(this._GCustomer_ID))
					{
						MessageBox.Show("Không thể xóa nhóm \"" + this.txtGCustomer_Name.Text + "\" vì đã có khách hàng hoặc nhà cung cấp thuộc nhóm này!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
						groupCustomers.loadToDataGridView(this.dgvGCustomer, this.bindingNavigator1);
					}
					else
					{
						groupCustomers.del(this._GCustomer_ID);
						groupCustomers.loadToDataGridView(this.dgvGCustomer, this.bindingNavigator1);
					}
				}
			}
			catch
			{
			}
		}
		private bool CheckGroupHavePartner(string tmpGroupID)
		{
			bool result = false;
			SqlConnection sqlConnection = new SqlConnection(Program.strConnectionString);
			sqlConnection.Open();
			try
			{
				SqlCommand sqlCommand = sqlConnection.CreateCommand();
				sqlCommand.CommandText = string.Concat(new string[]
				{
					"select AutoID  from TabPartner WHERE ([IsProvider] = 1 AND [ProGroup]='",
					tmpGroupID,
					"') OR ([IsCustomer] = 1 AND [CusGroup]='",
					tmpGroupID,
					"') "
				});
				SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
				if (sqlDataReader.HasRows)
				{
					result = true;
				}
				sqlDataReader.Close();
				sqlDataReader.Dispose();
			}
			catch
			{
			}
			sqlConnection.Close();
			sqlConnection.Dispose();
			return result;
		}
		private void FrmudtGroupCustomer_KeyDown(object sender, KeyEventArgs e)
		{
			if (e.KeyCode == Keys.F4)
			{
				this.tSBAdd.PerformClick();
			}
			else
			{
				if (e.KeyCode == Keys.F6)
				{
					this.tSBSave.PerformClick();
				}
				else
				{
					if (e.KeyCode == Keys.F8)
					{
						this.btnDel.PerformClick();
					}
					else
					{
						if (e.KeyCode == Keys.Escape)
						{
							base.Close();
						}
					}
				}
			}
		}
		private void dgvGCustomer_CellEnter(object sender, DataGridViewCellEventArgs e)
		{
			try
			{
				this._GCustomer_ID = this.dgvGCustomer.Rows[e.RowIndex].Cells["Column1"].Value.ToString();
				this.txtGCustomer_ID.Text = this._GCustomer_ID;
				groupCustomers groupCustomers = new groupCustomers();
				groupCustomers.getInfo(this._GCustomer_ID.ToString(), this.txtGCustomer_Name, this.txtGCustomer_Notes, this.txtDiscountIn, this.txtDiscountOut);
			}
			catch
			{
			}
		}
	}
}
